//
//  FQHelpTipCollectionViewCell.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/9/5.
//

import UIKit
import AttributedString

class FQHelpTipCollectionViewCell: UICollectionViewCell {
    let titleLb = QMUILabel(font: .rSFont(13), textColor: .color102)
    var actionBlock : (()->Void)? {
        didSet {
            var str : ASAttributedString = """
                    没有您想咨询的机构电话？\("点击这里", .font(.mSFont(13)), .foreground(.colorMain), .underline(.single), .action { [unowned self] in
                        if actionBlock != nil {
                            actionBlock!()
                        }
                    }) 查看所有机构官方客服电话
                    """
            str = str.add([.paragraph(.lineSpacing(5))], range: NSRange(location: 0, length: str.length))
            titleLb.attributed.text = str
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        layer.cornerRadius = 8
        clipsToBounds = true
        backgroundColor = .white
        
        titleLb.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
        titleLb.numberOfLines = 0
        titleLb.isUserInteractionEnabled = true
        contentView.addSubview(titleLb)
        
        titleLb.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
